home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xprof
/
event.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
115 lines
/*==================================================================
* File : event.c
* Package: Xprof
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
*==================================================================*/
/*
* Processing routines for the events seen in the message stream.
* Functions:
* 1. process_event(FILE *fp, char *string, GlobalStats *gstats)
* 2. print_event_stats(FILE *fp)
* 3. The routines to process each event seen. These have the format:
* Event(FILE *fp, event_index, current_time)
*/
#include <stdio.h>
#include "common.h"
MsgStats TotalEventStats; /* Overall stats for all events */
MsgStats EventStats[MAXEVENTS]; /* Detailed stats for each event */
/*static char in_string[MAXSTRINGSIZE];*/ /* Buffer to read a record into */
static char sbuf[132]; /* Temp. slots for sscanf*/
extern MsgType EventType[];
extern int lookup_event();
process_event(fp, string, gstats)
FILE *fp;
char *string;
GlobalStats *gstats;
{
char event_name[80]; /* Name of the current event */
int event_index; /* Index in the data structures*/
long bytes=0; /* Number of bytes */
if (TotalEventStats.invoked == FALSE)
InitMsgStats(&TotalEventStats, gstats->current_time, DETAILED, GRAIN1);
sscanf(string, "%s %s",sbuf, event_name);
event_index = lookup_event(event_name);
/* Call the action for this event */
bytes=EventType[event_index].action(fp, event_index, gstats->current_time);
/*
* Fill the data structures for all the events.
*/
FillMsgStats(&TotalEventStats, gstats->current_time, bytes, bytes);
gstats->event_bytes += bytes;
}
print_event_stats(fp)
FILE *fp;
{
int i;
static char *dashes = {
"---------------------------------------------------------------"};
if (TotalEventStats.invoked == FALSE)
return;
/*
* Print the details for all Events together
*/
PrintMsgStats(fp,&TotalEventStats, "EVENTS ");
/*
* Brief table for the numbers and byte totals for the events
*/
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"%-25s", " EVENT messages");
fprintf(fp,"%25s", "Total Bytes ");
fprintf(fp," %19s\n","Number ");
fprintf(fp,"\t%s\n", dashes);
for (i = 0; i < MAXEVENTS; i++)
if (EventStats[i].invoked == TRUE) {
fprintf(fp,"%-25s", EventType[i].name);
fprintf(fp," %10ld bytes",EventStats[i].total_bytes);
fprintf(fp," (%5.2f%%)", (float) 100 * EventStats[i].total_bytes /
TotalEventStats.total_bytes);
fprintf(fp," %10ld", EventStats[i].number );
fprintf(fp," (%5.2f%%)", (float) 100 * EventStats[i].number /
TotalEventStats.number);
fprintf(fp,"\n");
}
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"%25s"," Grand Total ");
fprintf(fp," %10ld bytes ", TotalEventStats.total_bytes);
fprintf(fp," %10ld \n", TotalEventStats.number);
fprintf(fp,"\t%s\n", dashes);
if (verboselevel > 0) {
for (i = 0; i < MAXEVENTS; i++)
if (EventStats[i].detailed == DETAILED)
PrintMsgStats(fp,&EventStats[i], EventType[i].name);
}
/*
* Now dump the raw statistics for the messages
*/
if (verboselevel > 1) {
if (TotalEventStats.detailed == DETAILED)
PrintMsgDetails(fp,&TotalEventStats, "EVENTS ");
for (i = 0; i < MAXEVENTS; i++)
if (EventStats[i].detailed == DETAILED)
PrintMsgDetails(fp,&EventStats[i], EventType[i].name);
}
return;
}